Skip to content

feat: Freya OpenRouter operator and approachable UI - #9

Open
surrealwolf wants to merge 9 commits into
mainfrom
feat/freya-operator-openrouter
Open

surrealwolf wants to merge 9 commits into
mainfrom
feat/freya-operator-openrouter

Conversation

@surrealwolf

@surrealwolf surrealwolf commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Rebuild Freya around a Rust kube-rs operator (FreyaStudio, generations, styles, diffusion workers, model assets) instead of shipping ComfyUI/SwarmUI as the default path
  • Add Freya API + web UI for intent → plan/enhance → generate via OpenRouter, with optional in-cluster or remote diffusion workers and Civitai API key search/install for LoRAs
  • Move the previous Compose/Comfy/Swarm/Ollama stack under legacy/ for reference

Test plan

  • cargo test --workspace and make vet pass
  • make run-api with OPENROUTER_API_KEY; UI via cd web && npm i && npm run dev
  • Settings: save OpenRouter + Civitai keys; Civitai search (and install when a worker URL is set)
  • make manifests generates CRDs; sample FreyaStudio / external worker YAMLs look correct
  • Confirm legacy/ still contains the prior Compose docs and Makefiles

Made with Cursor


Note

High Risk
Large architectural cutover with new API auth, secret handling (OpenRouter/Civitai/worker tokens), and K8s operator reconciling deployments—misconfiguration could expose endpoints or break existing Compose users expecting root-level make up.

Reviewed by Cursor Bugbot for commit c9bb5e0. Bugbot is set up for automated code reviews on this repo. Configure here.

surrealwolf and others added 4 commits May 29, 2026 07:22
The UI update button pulls source but Freya skips the native rebuild step.
Wire git pull + dotnet build into make targets and document the workflow.

Co-authored-by: Cursor <[email protected]>
Stop only ComfyUI to preserve git state, use fetch+reset with retries,
and skip rebuild/restart when SwarmUI is already current.

Co-authored-by: Cursor <[email protected]>
Clear root for OpenRouter operator rebuild while keeping prior UI tooling reachable.

Co-authored-by: Cursor <[email protected]>
Replace Compose/GPU UI default path with kube-rs studio, cloud+local
generation router, and Civitai key install flow.

Co-authored-by: Cursor <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-worker/src/main.rs Resolved
Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-api/src/main.rs Resolved
Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-api/src/civitai.rs Resolved
Comment thread crates/freya-worker/src/main.rs Resolved
Comment thread web/nginx.conf Resolved
Comment thread crates/freya-api/src/gallery.rs Resolved
cursor[bot]
cursor Bot previously approved these changes Nov 21, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Approved. Cursor Bugbot skipped, so that automated-review signal was not used. Remaining configured signals and review state do not require human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

Keep Freya operator Makefile/README; Compose SwarmUI updates already live under legacy/.

Co-authored-by: Cursor <[email protected]>
@surrealwolf
surrealwolf dismissed cursor[bot]’s stale review November 21, 2026 06:34

The merge-base changed after approval.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread crates/freya-api/src/state.rs Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Not approved. Cursor Bugbot completed on this head and reported 14 unresolved findings that need human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

surrealwolf and others added 2 commits November 20, 2026 23:37
Interactive mock/dev:mock path, lacquer mist theme, portrait icons,
and suggest/session instruction packs with API assist enrichment for #9.

Co-authored-by: Cursor <[email protected]>
Root compose moved with the operator cutover; Lint and Validate was
failing with "no configuration file provided".

Co-authored-by: Cursor <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 5 potential issues.

There are 19 total unresolved issues (including 14 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a9a2954. Configure here.

Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread web/src/App.jsx Resolved
Comment thread web/src/App.jsx Resolved
Comment thread web/src/App.jsx Resolved
Comment thread web/src/App.jsx Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approved. Cursor Bugbot reviewed this head and reported 19 unresolved findings that need human review. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Comment thread crates/freya-api/src/main.rs Resolved
Comment thread crates/freya-api/src/routes.rs Resolved
Comment thread crates/freya-worker/src/main.rs Resolved
Contain asset dest paths, allowlist Civitai download hosts, optional
FREYA_API_TOKEN + tighter CORS, drop shell eval on asset Jobs, and
fix external worker URL / Job phase / LoRA local backend wiring.

Co-authored-by: Cursor <[email protected]>
@cursor

cursor Bot commented Nov 21, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: ee193dd6-4be1-46ee-8688-fa51b7867802)

cursor[bot]
cursor Bot previously approved these changes Nov 21, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot skipped on this head, so that automated-review signal was not used. Remaining configured signals and review state do not require human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Agentic security review of the latest head: residual HIGH issues remain around fail-open API auth (operator never injects FREYA_API_TOKEN), GET routes that still invoke stored provider keys, and unauthenticated worker asset install/SSRF. Prior findings on Civitai token leakage to arbitrary hosts, destPath traversal, and Job eval injection are addressed.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread crates/freya-api/src/main.rs Resolved
Comment thread crates/freya-api/src/main.rs Resolved
Comment thread crates/freya-worker/src/main.rs Resolved
Require bearer on protected GETs, wire apiTokenSecretRef and
worker authSecretRef through the operator, and allowlist worker
install hosts so cluster/Ingress deployments are not fail-open.

Co-authored-by: Cursor <[email protected]>
@cursor

cursor Bot commented Nov 21, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 5b86fa20-efba-447c-9204-bd59bffb4ce2)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot skipped on this head, so that automated-review signal was not used. Remaining configured signals and review state do not require human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agentic security review of the current head found three remaining issues: the UI proxy still presents a documented API bearer as if Ingress were authenticated, FreyaModelAsset can send a namespace Secret to an arbitrary download URL, and assist mode can read arbitrary .txt files as the system prompt.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread web/nginx.conf
proxy_http_version 1.1;
proxy_set_header Host $host;
# Injected when FreyaStudio apiTokenSecretRef is set (empty = open local/dev).
proxy_set_header Authorization "Bearer ${FREYA_API_TOKEN}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: HIGH

The UI nginx location for /v1/ always overwrites Authorization with FREYA_API_TOKEN. Ingress sends / to this UI Service, so any client that can load the studio (Internet when Ingress is enabled; any in-cluster pod otherwise) can call generate, PUT /v1/settings, and POST /v1/civitai/install without knowing the bearer. Direct hits to the API Service still require the token, which is what apiTokenSecretRef is documented to enforce for non-dev/Ingress.

Impact: Callers can persist provider keys, retarget diffusionWorkerUrl, spend OpenRouter credits, and drive worker installs as the studio.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit c9bb5e0. Configure here.

esac
mkdir -p "$(dirname "$DEST")"
if [ -n "${ASSET_TOKEN:-}" ]; then
curl -fL -H "Authorization: Bearer ${ASSET_TOKEN}" -o "$DEST" -- "$ASSET_URL"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: HIGH

The in-cluster download Job attaches FreyaModelAsset.spec.secretRef as ASSET_TOKEN and sends it as Authorization: Bearer to spec.url with curl -fL (redirects, no host allowlist). That is weaker than civitai_install, which already refuses non-Civitai hosts before attaching a key. A principal who can create FreyaModelAsset in the namespace does not need get secrets to coerce the operator into presenting another Secret in that namespace to an attacker URL.

Impact: Namespace secrets referenced by secretRef can leave the cluster in the Authorization header of a caller-controlled download.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit c9bb5e0. Configure here.

}

pub async fn load_instruction(packs_dir: &Path, mode: &str) -> String {
let path = packs_dir.join("instructions").join(format!("{mode}.txt"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: MEDIUM

load_instruction joins attacker-controlled AssistRequest.mode into {packs}/instructions/{mode}.txt with no allowlist, no .. rejection, and no containment check. On Unix, an absolute mode replaces the base path via Path::join. A successful read becomes the OpenRouter system prompt. POST /v1/assist is on the public /v1 surface (and is reachable through the UI proxy without a caller-supplied bearer).

Impact: A network caller can make the API process read any .txt file it can open and send those contents to OpenRouter.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit c9bb5e0. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant